<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../Vue全家桶_stu/03_依赖包/vue.js"></script>
</head>

<body>
    <div id="root">
        <!-- v-on 绑定事件 简写@ -->
        <h6>{{count}}</h6>
        <!-- 点击事件(同一个dom元素可以绑定多个事件) -->
        <button v-on:click="handler1" @mouseover="handler1">点击+1</button>
        <!-- 事件传递参数 -->
        <button @click="handler2('王麻子')">传递一个参数</button>
        <!-- 传递事件对象参数 -->
        <button @click="handler3($event,'王麻子')">传递事件对象参数</button>
    </div>
    <script>
        const vm = new Vue({
            el: '#root',
            data() {
                return {
                    count: 0
                }
            },
            methods: {
                handler1(event) {
                    //函数不传递参数时，浏览器传递event对象
                    console.log(event)
                    console.log(event.target.innerText)
                    console.log('handler1')
                    this.count++
                },
                handler2(value) {
                    console.log('传递的一个参数为' + value)
                },
                handler3(event, value) {
                    //函数传递参数时，event需要自己传递($event)
                    console.log(event)
                    console.log(value)
                }
            }

        })
    </script>
</body>

</html>